﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Point2d.Graphics
{
    public class MathUtil
    {
        public static float __PI = 3.1415926f;

        public static void RotateDir(float fromX, float fromY, float angle, ref float toX, ref float toY)
        {
            float angleOfRadian = angle * __PI / 180;

            toX = (float)(fromX * Math.Cos(angleOfRadian) + fromY * Math.Sin(angleOfRadian));
            toY = (float)(-1.0f * fromX * Math.Sin(angleOfRadian) + fromY * Math.Cos(angleOfRadian));

            float length = (float)(Math.Sqrt(toX * toX + toY * toY));
            toX = toX / length;
            toY = toY / length;
        }
    }
}
